﻿using ajayumi.develop.VBasic.Core.Net;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ajayumi.develop.VBasic.Core;

namespace ajayumi.develop.win32.Test
{
    public partial class Form1 : Form
    {

        public Form1()
        {
            InitializeComponent();

        }

        void SetText(string text)
        {
            if (this.richTextBox1.InvokeRequired)
            {
                this.richTextBox1.Invoke(new Action<string>(this.SetText), new object[] { text });
            }
            else
            { this.richTextBox1.Text = text; }
        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            //Uri siteUri = StringHelper.GetSafeUri("http://img4.ppmsg.com/Upload2010/58/hswmsnSarayycqxm/01.jpg", null);
            //Uri siteUri = StringHelper.GetSafeUri("http://www.6642.com", null);
            //using (WebAssistant assistant = new WebAssistant(siteUri, "http://www.6642.com"))
            //{
            //    WebDocumentInfo doc = assistant.GetHtmlCode();
            //    Console.WriteLine(doc.Title);
            //    //byte[] data = assistant.DownloadData();
            //    //using (System.IO.FileStream fs = new System.IO.FileStream(@"C:\ajayumi\Temp\1.jpg", System.IO.FileMode.CreateNew))
            //    //{
            //    //    fs.Write(data, 0, data.Length);
            //    //}

            //    //assistant.DownloadFile(@"E:\2.jpg");
            //}

            //Uri siteUri = StringHelper.GetSafeUri("http://www3.wkdown.info/fs3/down.php", null);
            //using (WebAssistant assistan=new WebAssistant(siteUri))
            //{
            //    assistan.Method = WebAssistant.MethodType.Post;
            //    assistan.Referer = "http://www3.wkdown.info/fs3/file.php/MKD5ADD.html";
            //    assistan.DownloadData("type=torrent&id=MKD5ADD&name=xxx-av.com-20876-FHD");
            //}

            Uri siteUri = StringHelper.GetSafeUri("http://www3.wkdown.info/fs3/down.php", null);
            using (WebAssistant assistan = new WebAssistant(siteUri))
            {
                assistan.Method = WebAssistant.MethodType.Post;
                assistan.PostDataStr = "type=torrent&id=MKD5ADD&name=xxx-av.com-20876-FHD";
                assistan.Referer = "http://www3.wkdown.info/fs3/file.php/MKD5ADD.html";
                assistan.DownloadFile(@"c:\ajayumi\temp.torrent");
            }
        }
    }
}
